package cn.edu.sdyu.ie.crs.repository;

import cn.edu.sdyu.ie.crs.common.response.LabelValue;
import cn.edu.sdyu.ie.crs.domain.Classroom;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

@Repository
public interface ClassroomRepository extends JpaRepository<Classroom, Integer> {

    @Query(value = "SELECT c.usage_mode AS label, count(*) AS value"
            + " FROM classroom c"
            + " WHERE c.usage_mode IS NOT NULL"
            + " GROUP BY c.usage_mode", nativeQuery = true)
    List<LabelValue> countGroupByUsageMode();

    List<Classroom> findByLocation(Integer location);

}
